package com.ruoyi.his.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.his.domain.NewHisSchedule;
import com.ruoyi.his.service.INewHisScheduleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * newscheduleController
 * 
 * @author ruoyi
 * @date 2025-03-14
 */
@RestController
@RequestMapping("/his/newschedule")
public class NewHisScheduleController extends BaseController
{
    @Autowired
    private INewHisScheduleService newHisScheduleService;

    /**
     * 查询newschedule列表
     */
    @GetMapping("/list")
    public TableDataInfo list(NewHisSchedule newHisSchedule)
    {
        startPage();
        List<NewHisSchedule> list = newHisScheduleService.selectNewHisScheduleList(newHisSchedule);
        return getDataTable(list);
    }

    /**
     * 导出newschedule列表
     */

    @Log(title = "newschedule", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NewHisSchedule newHisSchedule)
    {
        List<NewHisSchedule> list = newHisScheduleService.selectNewHisScheduleList(newHisSchedule);
        ExcelUtil<NewHisSchedule> util = new ExcelUtil<NewHisSchedule>(NewHisSchedule.class);
        util.exportExcel(response, list, "newschedule数据");
    }

    /**
     * 获取newschedule详细信息
     */

    @GetMapping(value = "/{schedId}")
    public AjaxResult getInfo(@PathVariable("schedId") Long schedId)
    {
        return AjaxResult.success(newHisScheduleService.selectNewHisScheduleBySchedId(schedId));
    }

    /**
     * 新增newschedule
     */

    @Log(title = "newschedule", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NewHisSchedule newHisSchedule)
    {
        return toAjax(newHisScheduleService.insertNewHisSchedule(newHisSchedule));
    }

    /**
     * 修改newschedule
     */

    @Log(title = "newschedule", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NewHisSchedule newHisSchedule)
    {
        return toAjax(newHisScheduleService.updateNewHisSchedule(newHisSchedule));
    }

    /**
     * 删除newschedule
     */

    @Log(title = "newschedule", businessType = BusinessType.DELETE)
	@DeleteMapping("/{schedIds}")
    public AjaxResult remove(@PathVariable Long[] schedIds)
    {
        return toAjax(newHisScheduleService.deleteNewHisScheduleBySchedIds(schedIds));
    }
}
